Skip to content

16进制格式颜色转为RGB - Hex2RGB

函数简介

将16进制格式的颜色字符串转换为RGB颜色分量。

接口名称

Hex2RGB

DLL调用

int Hex2RGB(long ola, string hex, int* r, int* g, int* b);

参数说明

参数名类型说明
ola长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
hex字符串16进制颜色值,支持RRGGBB或AARRGGBB格式
r整数型指针返回红色分量值,范围0-255
g整数型指针返回绿色分量值,范围0-255
b整数型指针返回蓝色分量值,范围0-255

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.Hex2RGB("value", "value", "value", "value");
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.Hex2RGB("value", "value", "value", "value");
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.Hex2RGB("value", "value", "value", "value")
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.Hex2RGB("value", "value", "value", "value");
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.Hex2RGB("value", "value", "value", "value")
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.Hex2RGB("value", "value", "value", "value")
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.Hex2RGB(“value”, “value”, “value”, “value”)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.Hex2RGB("value", "value", "value", "value");
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.Hex2RGB("value", "value", "value", "value")
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t ret = ola.Hex2RGB("value", "value", "value", "value");

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
Hex2RGB(instance, "value", 0, 0, 0);
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int Hex2RGB(long ola, string hex, int r, int g, int b);

long instance = CreateCOLAPlugInterFace();
Hex2RGB(instance, "value", 0, 0, 0);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.Hex2RGB(instance, "value", 0, 0, 0)

返回值

整数型:1 成功,0 失败。